package com.eascs.admin.sys.permission.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import com.eascs.admin.o2o.internal.util.StatusContexts;
import com.eascs.site.view.ViewContext;
import com.eascs.tag.MenuTag;
import com.eascs.workflow.common.entity.sys.SysResources;
import com.eascs.workflow.common.service.sys.SysPermissionService;
import com.eascs.workflow.common.vo.ModelResult;

@Controller
@RequestMapping("/act/resource")
public class ResourceController extends PermissionBaseMasterViewController {
	@Reference
	private SysPermissionService sysPermissionService;
	
	@Value("${o2o.admin.ztree.diycss}")
	private String diycss;//图标样式
	
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public String list() {
		ViewContext.put(MenuTag.CURRENT_MENU_CODE, "menuManage");
		ModelResult<List<SysResources>> modelResult = sysPermissionService.selectResourcesList();
		List<SysResources> list = modelResult.getModel();
		for(int i=0;i<list.size();i++){
			SysResources item = list.get(i);
			if(item.getResourceType()==StatusContexts.RESOURCE_TYPE_QX){
				item.setIconSkin(diycss);
			}
		}
		ViewContext.put("reso", JSON.toJSONString(list));
		return "/sys/resourceList";
	}
}
